package controller.entity;

import java.io.Serializable;

/**
 * Created by asus on 2017/6/18.
 */
public class Result implements Serializable{

    private int status;
    private String message;
    private Object result;

    private Result() {
    }

    public static Result success() {
        Result result = new Result();
        result.setStatus(200);
        return result;
    }

    public static Result success(Object obj) {
        Result result = new Result();
        result.setStatus(200);
        result.setResult(obj);
        return result;
    }

    public static Result success(String message, Object obj) {
        Result result = new Result();
        result.setStatus(200);
        result.setResult(obj);
        result.setMessage(message);
        return result;
    }

    public static Result fail(String message) {
        Result result = new Result();
        result.setStatus(301);
        result.setMessage(message);
        System.out.println(result);
        return result;
    }

    private void setStatus(int status) {
        this.status = status;
    }

    private void setResult(Object result) {
        this.result = result;
    }

    private void setMessage(String message) {
        this.message = message;
    }

    public int getStatus() {
        return status;
    }

    public String getMessage() {
        return message;
    }

    public Object getResult() {
        return result;
    }

    @Override
    public String toString() {
        return "Result{" +
                "status=" + status +
                ", message='" + message + '\'' +
                ", result=" + result +
                '}';
    }
}
